# -*- coding: utf-8 -*-
# @Author: Gemini by Tim Liu
# @Date: 2024-10-22
# @Last Modified by: Tim Liu
# @Last Modified time: 2024-10-22

from langchain.tools import StructuredTool
from crewplus.tools.platform.send_mail import EmailInput, MailTool

class ToolFactory:
    def create_tool(self, tool_name):
        if tool_name == "crewplus.send_email":
            # Create a MailTool instance with configuration (optional)
            mail_tool = MailTool()
            
            # Create a StructuredTool from the MailTool instance
            email_sender = StructuredTool.from_function(
                name="send_email",
                description="Send Email via SMTP. If you need to send email, use send_email",
                func=mail_tool.send_email,  # Use the method from the MailTool instance
                args_schema=EmailInput,
            )
            
            return email_sender
        elif tool_name == "web_search":
            #TODO: create web search tool, Tavily/Serper/...
            pass
        else:
            raise ValueError(f"Invalid tool name: {tool_name}")